package com.fenqing.comics.commons;

import com.fenqing.comics.utils.StrUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/**
 * 常量接口
 * @author fenqing
 */
public interface Constant {

    // 国家爬虫接口定时频率
    long COUNTRY_CRAWLER_INTERVAL = (long) 1000 * 60;

    // 作者和书籍爬虫默认从第几页开始
    int DEFAULT_PAGE_NUM = 1;

    // 作者和书籍爬虫每次爬取的数量
    int DEFAULT_PAGE_SIZE = 36;

    // ext no update
    String EXT_NO_UPDATE = "noUpdates";

    // ext page
    String EXT_PAGE = "page";

    // ext is end
    String EXT_IS_END = "isEnd";

    // 包子漫画爬取作者和漫画的触发频率
    long BZ_CRAWLER_INTERVAL = (long) 1000 * 60;

    List<Function<String, List<String>>> BZ_AUTHOR_HANDLES = List.of(
            str -> StrUtils.splitClean(str,","),
            str -> StrUtils.splitClean(str,"作者: "),
            str -> StrUtils.splitClean(str,"/"),
            str -> StrUtils.splitClean(str,"编绘: "),
            str -> StrUtils.splitClean(str,"制作人: "),
            str -> StrUtils.splitClean(str,"主笔: "),
            str -> StrUtils.splitClean(str,"&"),
            str -> StrUtils.splitClean(str,"原著: "),
            str -> StrUtils.splitClean(str,"（原著）+"),
            str -> StrUtils.splitClean(str,"（原著）"),
            str -> StrUtils.splitClean(str,"+"),
            str -> StrUtils.splitClean(str,"，"),
            str -> StrUtils.splitClean(str,"文："),
            str -> StrUtils.splitClean(str,"圖："),
            str -> StrUtils.splitClean(str,"  "),
            str -> StrUtils.splitClean(str," | "),
            str -> "）".equals(str) ? new ArrayList<>() : List.of(str),
            str -> str.startsWith("-") ? List.of(str.substring(1)) : List.of(str),
            str -> StrUtils.splitClean(str, "（主笔）")
    );
}
